<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
  
  <xsl:template name="relative-time">
    <xsl:param name="diff" />
      <xsl:choose>
      <xsl:when test="$diff &gt; 2419200"><xsl:value-of select="ceiling($diff div 2419200)" />mo ago</xsl:when>
      <xsl:when test="$diff &gt; 85000"><xsl:value-of select="ceiling($diff div 87600)" />d ago</xsl:when>
      <xsl:when test="$diff &gt; 3600"><xsl:value-of select="ceiling($diff div 3600)" />h ago</xsl:when>
      <xsl:when test="$diff &gt; 3400">about an hour ago</xsl:when>
      <xsl:when test="$diff &gt; 1800">less than an hour ago</xsl:when>
      <xsl:when test="$diff &gt; 60"><xsl:value-of select="floor($diff div 60)" />m ago</xsl:when>
      <xsl:when test="$diff &gt; 5">less than a minute ago</xsl:when>
      <xsl:otherwise>just now</xsl:otherwise>
      </xsl:choose>
  </xsl:template>
  
  <xsl:template name="auto-action">
    <xsl:param name="m" />
    <xsl:choose>
      <xsl:when test="contains('anime|adrama|film|tv', $m)"><xsl:text>watched </xsl:text></xsl:when>
      <xsl:when test="contains('blog|comic|literature|manga|periodical|lightnovel|vn', $m)"><xsl:text>read </xsl:text></xsl:when>
      <xsl:when test="$m = 'vg'"><xsl:text>played </xsl:text></xsl:when>
      <xsl:when test="$m = 'music'"><xsl:text>listening to </xsl:text></xsl:when>
    </xsl:choose>
  </xsl:template>
  
  <xsl:template name="auto-segment">
    <xsl:param name="m" />
    <xsl:choose>
      <xsl:when test="contains('anime|adrama|tv', $m)">episode/%23</xsl:when>
      <xsl:when test="contains('literature|manga|lightnovel|vn', $m)">chapter/%23</xsl:when>
      <xsl:when test="contains('comic|periodical', $m)">issue/issue%20no</xsl:when>
      <xsl:when test="$m = 'music'">track/trackname</xsl:when>
    </xsl:choose>
  </xsl:template>
  
</xsl:stylesheet>
